﻿using System;
using System.Windows.Forms;

namespace WindowsApplication2._8_加解密
{
    public partial class base64_encode : Form
    {
        public base64_encode()
        {
            InitializeComponent();
        }

        /// <summary>
        /// jia mi
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string strin = this.textBox1.Text;

            byte[] encbuff = System.Text.Encoding.UTF8.GetBytes(strin);
            String enc = Convert.ToBase64String(encbuff);

            this.textBox2.Text = enc;
        }

        /// <summary>
        /// jiemi
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            string strin = this.textBox1.Text;

            //byte[] encbuff = System.Text.Encoding.UTF8.GetBytes(strin);
            //String enc = Convert.FromBase64String(strin);

            byte[] encbuff = Convert.FromBase64String(strin);
            String enc = System.Text.Encoding.UTF8.GetString(encbuff);

            this.textBox2.Text = enc;
        }
    }
}